#! /bin/sh

VERSION=${1}

if [ -z "${VERSION}" ]; then
    echo "ERROR: version is empty!"
    exit 1
fi

SRC_DIR="surcloud-gateway-$VERSION"
SRC_TAR="${SRC_DIR}.tar.gz"

rm -rf ${SRC_DIR}
rm -f ${SRC_TAR}

mkdir $SRC_DIR

tar czf $SRC_TAR $SRC_DIR
mv $SRC_TAR ~/rpmbuild/SOURCES
rm -rfv ${SRC_DIR}

sed -e "s/__VERSION__/${VERSION}/g" rpm/surcloud-gateway.spec > \
    ~/rpmbuild/SPECS/surcloud-gateway.spec

echo $SRC_DIR

# cp ~/rpmbuild/SPECS
# rpmbuild -bb surcloud-gateway.spec
